package com.example.android_entrainement;

import android.R;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * Created by jim on 20/07/13.
 */
public class DisplayMessageActivity extends Activity {

    HearthstoneSQLiteDB howDB;

    @SuppressLint("NewApi")
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(com.example.android_entrainement.R.layout.manage_db);


        CSVtoCardDb managerCSV = new CSVtoCardDb();
        try{

        ArrayList<CardEntity> image_details = managerCSV.GetListCardsFromCSV(new InputStreamReader(getAssets().open("BD_HOW.csv")));

        CardListViewAdapter adap = new CardListViewAdapter(getApplicationContext(),com.example.android_entrainement.R.layout.cards_list_row, image_details);

        final ListView lv1 = (ListView) this.findViewById(com.example.android_entrainement.R.id.cards_listview);

        lv1.setAdapter(adap);

        lv1.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> a, View v, int position, long id) {
                Object o = lv1.getItemAtPosition(position);
                CardEntity newsData = (CardEntity) o;
                Toast.makeText(DisplayMessageActivity.this, "Selected :" + " " + newsData, Toast.LENGTH_LONG).show();
            }

        });


        }
        catch (IOException e)
        {

        }

    }

    }

